import React, { Component } from 'react';
import { View, TouchableWithoutFeedback, Image } from 'react-native';
import { directToPage } from '../../utils/extension';
import AniImage from '../AniImage';

class SwiperItem extends Component{
  render() {
    const { data, styles, navigation } = this.props;
    //按压屏幕触发跳转至详情页面
    const toDetailPage = () => {
      directToPage(navigation, 'Detail', {
        courseId: data.course_id
      });
    }

    return (
      <TouchableWithoutFeedback
        style={styles.swiperSize}
        onPress={toDetailPage}
      >
        {/* 深坑：在react-native v0.68中url改为uri 否则图片无法显示*/}
        <AniImage
          styles={styles.swiperSize}
          uri={ data.img }
        />
      </TouchableWithoutFeedback>
    );
  }
}

export default SwiperItem;